package edu.bbu.bibliospring.backend.model;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by anna on 6/4/14.
 */

@Entity
@Table(name = "message")
//@IdClass(BaseEntity.class)
public class Message extends BaseEntity {

    private static final long serialVersionUID = 1L;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="location", referencedColumnName = "id")
    protected Location senderLibrary;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="profile", referencedColumnName = "id")
    protected Profile receiver;
    protected String messageContent;
    @Temporal(TemporalType.DATE)
    protected Date sentOn;

    public Message() {}

    public Message(Location senderLibrary, Profile receiver, String messageContent, Date sentOn) {
        this.senderLibrary = senderLibrary;
        this.receiver = receiver;
        this.messageContent = messageContent;
        this.sentOn = sentOn;
    }

    public Location getSenderLibrary() {
        return senderLibrary;
    }

    public void setSenderLibrary(Location senderLibrary) {
        this.senderLibrary = senderLibrary;
    }

    public Profile getReceiver() {
        return receiver;
    }

    public void setTo(Profile receiver) {
        this.receiver = receiver;
    }

    public String getMessageContent() {
        return messageContent;
    }

    public void setMessageContent(String messageContent) {
        this.messageContent = messageContent;
    }

    public Date getSentOn() {
        return sentOn;
    }

    public void setSentOn(Date sentOn) {
        this.sentOn = sentOn;
    }
}
